package com.tankgame;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class HspTankGame extends JFrame {

    //定义MyPanel
    MyPanel mp=null;
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        HspTankGame hs01=new HspTankGame();
    } 
    public HspTankGame(){
        System.out.println("请输入选择 1：新游戏 2：继续上局");
        String key=sc.next();
        mp=new MyPanel(key);
        //将mp放入到Thread，并启动
        Thread thread = new Thread(mp);
        thread.start();
        this.add(mp);//把面板（就是游戏的绘图区域）
        this.setSize(1300,750);
        this.addKeyListener(mp);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        //在JFram中增加相应关闭窗口的处理
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
//                System.out.println("监听到关闭窗口");
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }
}
